var api = require('../../util/api.js');
Page({
  data: {

  },
  onLoad: function () {
    let _this = this;
    api.getDic('lhjd_type').then(res => {
      _this.setData({
        examineType: res
      });
    });

    this.setData({
      page: api.page(10),
      dataList: []
    });
    this.onReachBottom();
  },
  onPullDownRefresh() {
    this.setData({
      page: api.page(10),
      dataList: []
    });
    this.loadList();
  },
  onReachBottom() {
    this.loadList();
  },
  loadList() {
    var _this = this;
    var params = _this.data.params;
    var page = _this.data.page;
    api.get(api.url.examineList, params, page).then(res => {
      page.setTotal(res.total);
      if (res.rows.length == 0) {
        this.setData({
          hasData: false
        })
      } else {
        _this.setData({
          hasData: true,
          dataList: _this.data.dataList.concat(res.rows)
        });
      }
    })
  },
  goConfig: function (e) {
    api.chain({
      examineStatus: e.currentTarget.dataset.status,
      examineId: e.currentTarget.dataset.id
    });
    let subType = e.currentTarget.dataset.subType;
    if(subType == '1'){//试油监督
      wx.navigateTo({
        url: `../examine_item/config`
      });
    }else if(subType == '2'){//钻井监督
      wx.navigateTo({
        url: `../../zjjd/examine_item/config`
      });
    }else if(subType == '3'){//测井监督
      wx.navigateTo({
        url: `../../cjjd/examine_item/config`
      });
    }else if(subType == '4'){//录井监督
      wx.navigateTo({
        url: `../../ljjd/examine_item/config`
      });
    }
  },
  goAddContest: function () {
    api.chain({});
    wx.navigateTo({
      url: "./add"
    });
  }
});